USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_TRANS_CSPF000_TEMP]    Script Date: 11/24/2011 14:37:40 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0002_TRANS_CSPF000_TEMP]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0002_TRANS_CSPF000_TEMP]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_TRANS_CSPF000_TEMP]    Script Date: 11/24/2011 14:37:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


/*
EXEC sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

EXEC sp_configure 'Ad Hoc Distributed Queries', 1;

GO

RECONFIGURE;

GO
*/
CREATE PROCEDURE [dbo].[WASP_M0002_TRANS_CSPF000_TEMP]
AS
BEGIN
	-- T-SQL OPENROWSET from excel  worksheet
	-- Import Excel data  into global temporary table
	DECLARE @SQLconnect VARCHAR(8000), @FileName varchar(256)

	SET @FileName='C:\Temp\Top10.xls'
	SET @SQLconnect = 'SELECT * INTO ##tmpOrders FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @FileName + ''', ''SELECT * FROM [Sheet1$]'')'

	PRINT @SQLconnect
	-- SELECT * INTO ##tmpOrders FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=F:\data\export\excel\Top10.xls', 'SELECT * FROM [Sheet1$]')
	EXEC (@SQLconnect)

	SELECT * FROM ##tmpOrders

	SELECT COUNT(*) FROM ##tmpOrders
	-- 2452

	DROP TABLE ##tmpOrders
	
/*	
	SELECT	'cragencia' AS CRAGENCIA
			,'Crcredito' AS CRCREDITO
			,'CRMARCA' AS CRMARCA
			,'CRRUTDEUDO' AS CRRUTDEUDO
			,'CRDVEDEUDO' AS CRDVEDEUDO
			,'CRRUTCOD1' AS CRRUTCOD1
			,'CRDVECOD1' AS CRDVECOD1
			,'CRRUTCOD2' AS CRRUTCOD2
			,'CRDVECOD2' AS CRDVECOD2
			,'CRRUTEMPRE' AS CRRUTEMPRE
			,'CRDVEEMPRE' AS CRDVEEMPRE
			,'CRCLASE' AS CRCLASE
			,'CRCUOTAS' AS CRCUOTAS
			,'CRFECAPROB' AS CRFECAPROB
			,'CRVALCUOTA' AS CRVALCUOTA
			,'CRDIASPRIM' AS CRDIASPRIM
			,'CRMONTO' AS CRMONTO
			,'CRORIGEN' AS CRORIGEN
			,'CRSEGURO' AS CRSEGURO
			,'CRTASA' AS CRTASA
			,'CRESPECIAL' AS CRESPECIAL
			,'CRMODIFICA' AS CRMODIFICA
			,'STSMODREGC' AS STSMODREGC
			,'FMODIFREGC' AS FMODIFREGC
			,'USRMODREGC' AS USRMODREGC
			,'CRINDICA' AS CRINDICA
			,'CRSERIE' AS CRSERIE
			,'CRNOTARIO' AS CRNOTARIO
			,'CRIMPUESTO' AS CRIMPUESTO
			,'CRCOMISION' AS CRCOMISION
			,'USRMODAPRO' AS USRMODAPRO
			,'CRFECRELIQ' AS CRFECRELIQ
			,'USRMODRELI' AS USRMODRELI
			,'CRGASTOPER' AS CRGASTOPER
			,'CRMONABONA' AS CRMONABONA
			,'CRESTADO' AS CRESTADO
			,'CRSEGDESGR' AS CRSEGDESGR
			,'CRSTSVGTE' AS CRSTSVGTE
			,'CRSTSMORA' AS CRSTSMORA
			,'CRAGECOLOC' AS CRAGECOLOC
			,'FILLER' AS FILLER
			,'ENDEUD_MAXIMO' AS ENDEUD_MAXIMO
			,'disponible' AS DISPONIBLE
			,'analista' AS ANALISTA
			,'ESTADOTRAB' AS ESTADOTRAB
			,'cancelado' AS cancelado
			,'TIPO_CLIENTE' AS CRTIPCLIE
			,'ubnom' AS COD_ANALISTA
			,'RUTDEUDOR' AS  RUTDEUDOR
			,'TIPO_CREDITO' AS TIPO_CREDITO
			,'Solicitante' AS Solicitante
			,'CTABANTOTAL' AS CTABANTOTAL
			,'MTOLIQ' AS CRMONTO_LIQ
			,'CRSEGCesantia' AS CRSEGCesantia
			,'crsegsalud' AS CRSegsalud
*/
/*	SELECT	cragencia AS CRAGENCIA
			,Crcredito AS CRCREDITO
			,CRMARCA AS CRMARCA
			,CRRUTDEUDO AS CRRUTDEUDO
			,CRDVEDEUDO AS CRDVEDEUDO
			,CRRUTCOD1 AS CRRUTCOD1
			,CRDVECOD1 AS CRDVECOD1
			,CRRUTCOD2 AS CRRUTCOD2
			,CRDVECOD2 AS CRDVECOD2
			,CRRUTEMPRE AS CRRUTEMPRE
			,CRDVEEMPRE AS CRDVEEMPRE
			,CRCLASE AS CRCLASE
			,CRCUOTAS AS CRCUOTAS
			,CRFECAPROB AS CRFECAPROB
			,CRVALCUOTA AS CRVALCUOTA
			,CRDIASPRIM AS CRDIASPRIM
			,CRMONTO AS CRMONTO
			,CRORIGEN AS CRORIGEN
			,CRSEGURO AS CRSEGURO
			,CRTASA AS CRTASA
			,CRESPECIAL AS CRESPECIAL
			,CRMODIFICA AS CRMODIFICA
			,STSMODREGC AS STSMODREGC
			,FMODIFREGC AS FMODIFREGC
			,USRMODREGC AS USRMODREGC
			,CRINDICA AS CRINDICA
			,CRSERIE AS CRSERIE
			,CRNOTARIO AS CRNOTARIO
			,CRIMPUESTO AS CRIMPUESTO
			,CRCOMISION AS CRCOMISION
			,USRMODAPRO AS USRMODAPRO
			,CRFECRELIQ AS CRFECRELIQ
			,USRMODRELI AS USRMODRELI
			,CRGASTOPER AS CRGASTOPER
			,CRMONABONA AS CRMONABONA
			,CRESTADO AS CRESTADO
			,CRSEGDESGR AS CRSEGDESGR
			,CRSTSVGTE AS CRSTSVGTE
			,CRSTSMORA AS CRSTSMORA
			,CRAGECOLOC AS CRAGECOLOC
			,FILLER AS FILLER
			,ENDEUD_MAXIMO AS ENDEUD_MAXIMO
			,disponible AS DISPONIBLE
			,analista AS ANALISTA
			,ESTADOTRAB AS ESTADOTRAB
			,cancelado AS cancelado
			,TIPO_CLIENTE AS CRTIPCLIE
			,ubnom AS COD_ANALISTA
			,RUTDEUDOR AS  RUTDEUDOR
			,TIPO_CREDITO AS TIPO_CREDITO
			,Solicitante AS Solicitante
			,CTABANTOTAL AS CTABANTOTAL
			,MTOLIQ AS CRMONTO_LIQ
			,CRSEGCesantia AS CRSEGCesantia
			,crsegsalud AS CRSegsalud
	FROM	[Bmig_Mensual_Post_Cadena].[dbo].[CSPF000_TEMP]
*/
END

GO


